package gat.api.rest.background.backgroundUser;

import javax.validation.Valid;

import gat.api.config.annotation.CheckPermissions;
import gat.api.config.annotation.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.bitsun.core.common.web.ResultDTO;

import gat.api.background.backgroundUser.BUserRoleApi;
import gat.application.backgroundUser.UserRoleService;
import gat.dto.req.backgroundUser.UserRoleReqDto;
import gat.dto.res.backgroundUser.UserRoleResDto;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;

/**
 * 权限用户关联表
 * @Author: tmac
 * @Email: tmac
 */
@Slf4j
@SuppressWarnings("unchecked")
@RestController
@RequestMapping("/userRole")
public class BUserRoleApiController implements BUserRoleApi {


    @Autowired
    private UserRoleService userRoleService;

    @Override
    @CheckPermissions(value = "userRole:save")
    @PostMapping(consumes = {"application/json"}, produces = {"application/json"})
    public ResultDTO<UserRoleResDto> addUserRole(
        @ApiParam(value = "要保存的对象", required = true) @Valid @RequestBody UserRoleReqDto reqDto) {
        UserRoleResDto resDto = userRoleService.save(reqDto);
        return ResultDTO.ok(resDto);
    }

}
